package com.eig.course.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.eig.common.entity.course.EduCourse;
import com.eig.common.entity.course.EduSubject;
import com.eig.common.entity.system.TbMember;
import com.eig.common.vo.Result;
import com.eig.course.service.CoreCourseService;
import com.eig.course.service.CoreService;
import com.eig.course.vo.EduCourseVo;
import com.eig.course.vo.EduSubjectVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.data.domain.PageRequest;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import javax.annotation.Resource;

/**
 * @author ：StudentLsj（李世界）
 * @date ：Created in 2022/12/06 下午 06:06
 * @description：
 * @modified By：
 * @version:
 */
@RestController
@RequestMapping("/core/course")
@Api(tags = "课程列表接口")
@EnableSwagger2
public class CoreCourseController {

    @Resource
    private CoreCourseService customerService;


    @PostMapping("/getmemberAll/{current}/{pageSize}")
    public Result<IPage<TbMember>> getTeacherByPage(@PathVariable(required = true) Integer current,
                                                    @PathVariable(required =true ) Integer pageSize,
                                                    @RequestBody TbMember tbMember
    ){
        return customerService.queryMemberList(current,pageSize,tbMember);
    }


    @PostMapping("/findCourse/{pageCurrent}/{pageSize}")
    @ApiOperation(value = "分页查询", notes = "根据current和pageSize查询")
    public Result findCourse(@PathVariable Integer pageCurrent, @PathVariable Integer pageSize, @RequestBody EduCourse e) {
        PageRequest pageRequest = PageRequest.of(pageCurrent - 1, pageSize);
        return customerService.queryByPage(e, pageRequest);
    }

    @PostMapping("/changeStatus")
    @ApiOperation(value = "上下架操作", notes = "根据 Draft 下架和 Normal 上架")
    public Result changeStatus(@RequestBody EduCourseVo e) {
        return customerService.changeStatus(e);
    }
    @PostMapping("/updateCourse")
    @ApiOperation(value = "修改操作", notes = "EduCourseVo")
    public Result updateCourse(@RequestBody EduCourseVo e) {
        return customerService.updateCourse(e);
    }
    @PostMapping("/updateCourseById")
    @ApiOperation(value = "远程调用修改操作")
    public Result updateCourseById(@RequestBody EduCourse e) {
        return customerService.updateCourseById(e);
    }
}
